package com.hiv.config;

import cn.hutool.core.lang.Console;
import com.hiv.common.Constants;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

@Configuration
public class CookieConfig {

    @Bean
    public StringRedisSerializer stringRedisSerializer(){
        return new StringRedisSerializer();
    }

    @Bean
    public DefaultCookieSerializer defaultCookieSerializer(){
        DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer();
        cookieSerializer.setCookieName(Constants.SESSIONID);
//        cookieSerializer.setDomainName(".shreker.org");
//        cookieSerializer.setDomainNamePattern("**");
        cookieSerializer.setUseHttpOnlyCookie(false);
//        cookieSerializer.setSameSite(SameSiteCookies.NONE.getValue());
        cookieSerializer.setCookiePath("/");
        cookieSerializer.setCookieMaxAge(180000000);
        Console.log("设置cookie属性");
        cookieSerializer.setUseBase64Encoding(false);
        // cookieSerializer.setSameSite(SameSiteCookies.NONE.getValue());
        return cookieSerializer;
    }
}